import router from '@system.router';

let timer = null

export default {
    data: {
        second: 3
    },
    onReady() {
        this.initTimer()
    },
    onDestroy() {
        clearInterval(timer)
    },
    initTimer() {
     timer = setInterval(()=>{
            this.second--
            if (this.second <= 0) {
                clearInterval(timer)
                this.timer = null
                router.replace({
                    uri: "pages/training/training",
                    params: {
                        time: this.time,
                        spend: this.spend
                    },
                })
            }
        },1000)
    }
}
